package cn.edu.hunau.java.week02.day04.Student;

import java.util.Comparator;
import java.util.Objects;

import static jdk.internal.org.jline.utils.Colors.s;

public class Student implements Comparable<Student> {
    private Integer sid;
    private String name;
    private String major;

    class SortStudent implements Comparator<Student>{
        @Override
        public int compare(Student o1, Student o2) {
            return o1.getName().length()-o2.getName().length();
        }
    }

    public Student() {
    }

    public Student(Integer sid, String name, String major) {
        this.sid = sid;
        this.name = name;
        this.major = major;
    }

    @Override
    public boolean equals(Object o) {
        if (o == null || getClass() != o.getClass()) return false;
        Student student = (Student) o;
        return Objects.equals(sid, student.sid) && Objects.equals(name, student.name) && Objects.equals(major, student.major);
    }

    @Override
    public int hashCode() {
        return Objects.hash(sid, name, major);
    }

    @Override
    public String toString() {
        return "Student{" +
                "sid=" + sid +
                ", name='" + name + '\'' +
                ", major='" + major + '\'' +
                '}';
    }

    public Integer getSid() {
        return sid;
    }

    public void setSid(Integer sid) {
        this.sid = sid;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getMajor() {
        return major;
    }

    public void setMajor(String major) {
        this.major = major;
    }

    @Override
    public int compareTo(Student o) {
        return this.sid-o.sid;
    }
}
